from AIUEOs import print_table, WordList, ToPing, Ping2Pian, Ping2rm
import random


def single():
    choose = input('1:平假名训练    2:片假名训练    else:罗马音训练\n').strip()
    if choose == '1':
        while True:
            word = random.choice(WordList)
            ping = word.ping
            pian = word.pian
            rm = word.rm
            print(ping, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(rm, pian)
            print()
    elif choose == '2':
        while True:
            word = random.choice(WordList)
            ping = word.ping
            pian = word.pian
            rm = word.rm
            print(pian, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(rm, ping)
            print()
    else:
        while True:
            word = random.choice(WordList)
            ping = word.ping
            pian = word.pian
            rm = word.rm
            print(rm, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(ping, pian)
            print()


def multi():
    choose = input('1:平假名训练    2:片假名训练    else:罗马音训练\n').strip()
    if choose == '1':
        while True:
            words = set(random.choices(WordList, k=random.randint(5, 12)))
            pings = [word.ping for word in words]
            pians = [word.pian for word in words]
            rms = [word.rm for word in words]
            print(*pings, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(*rms)
            print(*pians)
            print()
    elif choose == '2':
        while True:
            words = set(random.choices(WordList, k=random.randint(5, 12)))
            pings = [word.ping for word in words]
            pians = [word.pian for word in words]
            rms = [word.rm for word in words]
            print(*pians, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(*rms)
            print(*pings)
            print()
    else:
        while True:
            words = set(random.choices(WordList, k=random.randint(5, 12)))
            pings = [word.ping for word in words]
            pians = [word.pian for word in words]
            rms = [word.rm for word in words]
            print(*rms, end='')
            inp = input().strip()
            if not inp == '':
                break
            print(*pings)
            print(*pians)
            print()


def trans():
    while True:
        sentence = input('平假名或片假名:').strip()
        if sentence == '':
            break
        ping_sentence = ''
        for c in sentence:
            nc = ToPing[c]
            ping_sentence += nc
        print('\t'.join(ping_sentence))
        pian_sentence = ''
        rm_sentence = ''
        for c in ping_sentence:
            pian_sentence += Ping2Pian[c]
            rm_sentence += Ping2rm[c]+'\t'
        print('\t'.join(pian_sentence))
        print(rm_sentence)


if __name__ == '__main__':
    while True:
        choose = input('1.单字训练    2:多字训练    3.打印音图    4.平假片假句子转换    else:退出\n').strip()
        if choose == '1':
            single()
        elif choose == '2':
            multi()
        elif choose == '3':
            print_table()
        elif choose == '4':
            trans()
        else:
            break
